<template>
	<view class="">
		<u-navbar :is-back="false" :border-bottom="false" :background="background">
			<view class="d-flex a-center">
				<view class="pl-2 py-2"  @click="backtrack_img">
					<u-icon name="arrow-left" color="#ffffff" size="40"></u-icon>
				</view>
				<view class="font-lg font-weight text-white mx-2">客户详情</view>
				<u-icon name="zhuanfa" color="#ffffff" size="45" v-if="user.kehu_edit" @click="client_edit"></u-icon>
			</view>	
		</u-navbar>
		<view class="m-2 p-3 rounded-20 bg-white">
			<view class="d-flex">
				<view class=""><image class="terrace_img rounded-circle-50" :src="store_detail.user_picture?store_detail.user_picture:'../../static/images/order/default-photo.png'" mode=""></image></view>
				<view class="font-30 text-000 ml-2 mb-1">
					<view class="font-weight">
						<view class="font-30 line-h-md">
							姓名：{{store_detail.user_name}}
						</view>
						<view class="font-30 line-h-md">
							手机：{{store_detail.mobile_phone}}　昵称：{{store_detail.nickname}}
						</view>
						
						<view class="font-30 line-h-md">
							公司：{{store_detail.company_name}}
						</view>	
					</view>
					
					<!-- 
					<view class="font-weight font-35">{{store_detail.company_name}}</view>
					<view class="d-flex mt-1">
						<rich-text :nodes="store_detail.user_name"></rich-text><text class="ml-2">{{store_detail.mobile_phone}}</text>
					</view> -->
				</view>
			</view>
			<view class="d-flex">
				<view class="flex-1 text-center">
					<view class="text-666 my-2">累计交易额</view>
					<view class="font-lg text-000">{{store_detail.formatted_total_order_amount}}</view>
				</view>
				<view class="flex-1 text-center">
					<view class="text-666 my-2">累计订单数</view>
					<view class="font-lg text-000">{{store_detail.total_order_count}}</view>
				</view>
			</view>
		</view>
		<view class="m-2 px-3 bg-white rounded-10">
			<view class="py-3 d-flex j-sb border-bottom">
				<view class="font-weight font-35">客户级别</view>
				<view class="">
					<text class="text-999">{{store_detail.level_name}}</text>
				</view>
			</view>
			<view class="py-3 d-flex j-sb border-bottom">
				<view class="font-weight font-35">业务员</view>
				<view class="">
					<text class="text-999">{{store_detail.yewu_name}}</text>
				</view>
			</view>
			<view class="py-3 d-flex j-sb">
				<view class="font-weight font-35">客户标签</view>
				<view class="flex-1">
					<text class="text-999 ml-1 d-flex j-end" v-for="(item,index) in store_detail.tag_list" :key='index'>{{item.tag_name}}</text>
				</view>
			</view>
		</view>
		<view class="m-2 px-3 bg-white rounded-10" @click="recordTo">
			<view class="py-3 d-flex j-sb">
				<view class="font-weight font-35">交易记录</view>
				<view class="d-flex">
					<view class="text-999 mr-1">最近交易</view>
					<u-icon name="arrow-right" color="#909399" size="30"></u-icon>
				</view>
			</view>
		</view>
		<view class="m-2 px-3 bg-white rounded-10">
			<view class="py-3 d-flex j-sb border-bottom">
				<view class="font-weight font-35">所属地区</view>
				<view class="d-flex a-center">
					<text class="text-999">{{store_detail.city_name+store_detail.district_name}}</text>
				</view>
			</view>
			<view class="py-3 d-flex j-sb border-bottom">
				<view class="font-weight font-35">详细地址</view>
				<view class="d-flex">
					<text class="text-999">{{store_detail.address}}</text>
				</view>
			</view>
			<view class="py-3 d-flex j-sb">
				<view class="font-weight font-35">备注</view>
				<view class="d-flex">
					<text class="text-999 mr-1">{{store_detail.note}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				background: {
					background: '#fa7226',
				},
				their:"", // 所属地区
				minute:"", // 详细地址
				remarks:"", // 备注
				store_user_id:0, // 客户ID
				user_id:"", // 平台ID
				store_detail:"", // 客户详情
				
				user: {}
			}
		},
		methods:{
			backtrack_img(){
				uni.navigateBack({
					delta:1
				})
			},
			// 修改详情
			client_edit(){
				uni.navigateTo({
					url:`/pagesB/client/edit-client?store_user_id=${this.store_detail.store_user_id}&user_id=${this.user_id}`
				})
			},
			// 最近的交易记录
			recordTo(){
				uni.navigateTo({
					url:'/pagesB/client/deal-record?store_user_id='+this.store_user_id
				})
			},
			//  所属地区
			their_input(e){
				this.their=e.detail.value
			},
			// 详细地址
			minute_input(e){
				this.minute=e.detail.value
			}, 
			// 备注
			remarks_input(e){
				this.remarks=e.detail.value
			}, 
			
		},
		onShow() {
			this.$H.post("v2/store/user/detail",{
				store_user_id:this.store_user_id
			}).then(res=>{
				this.store_detail=res.data
			})
			
			
			let that=this
			if(uni.getStorageSync("toggle_default")){
				that.user=uni.getStorageSync("users") || {}
			}else if(uni.getStorageSync("toggle_demo")){
				that.user=uni.getStorageSync("users_demo") || {}
			}else{
				that.user=uni.getStorageSync("users") || {}
			}
		},
		onLoad(e) {
			
			if(e.isshow){
				this.$u.toast("此用户已存在");
			}
			
			this.user_id=e.user_id
			this.store_user_id=e.store_user_id
			this.$H.post("v2/store/user/detail",{
				store_user_id:this.store_user_id
			}).then(res=>{
				this.store_detail=res.data
			})
		}
	}
</script>

<style>
	.terrace_img{
		width: 120upx;
		height: 120upx;
	}
	.h_40{
		height: 40upx;
	}
	.font-30{
		font-size:30rpx
	}
</style>
